first()
will throw an exception if there is no suitable item in the list
(e.g., the list is empty).
In contrast, firstOrNull()
returns null
if there is no suitable item
in the list. So, in this case, noEvent
will be null
, as there is no
matching Event
.
You can learn more about this in:
Tags: